Matrix method to solve system of linear equations